<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1, user-scalable=no"/>
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../img/asset-favico.ico">
    <title>编辑信息</title>
    <link rel="stylesheet" href="../css/page-health-orderInfo.css"/>
    <link rel="stylesheet" href="../plugins/elementui/index.css"/>
    <script src="../plugins/jquery/dist/jquery.min.js"></script>
    <script src="../plugins/healthmobile.js"></script>
    <script src="../plugins/datapicker/datePicker.js"></script>
    <script src="../plugins/vue/vue.js"></script>
    <script src="../plugins/vue/axios-0.18.0.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script>
        var id = getUrlParam("id");
    </script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <style type="text/css">
        body, html {
            width: 100%;
            height: 100%;
            margin: 0;
            font-family: "微软雅黑";
        }

        #allmap {
            height: 300px;
            width: 750px;
        }

        #panorama {
            width: 100%;
            height: 500px;
        }

        #result {
            width: 100%;
            font-size: 12px;
        }
    </style>
    <script type="text/javascript"
            src="http://api.map.baidu.com/api?v=3.0&ak=zc8IbOv8nA8HxKHxHR1wvNw3IPAe4Lhs"></script>
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.js"></script>

</head>
<body data-spy="scroll" data-target="#myNavbar" data-offset="150">
<div id="app" class="app">
    <!-- 页面头部 -->
    <div class="top-header">
        <span class="f-left"><i class="icon-back" onclick="history.go(-1)"></i></span>
        <span class="center">传智健康</span>
        <span class="f-right"><i class="icon-more"></i></span>
    </div>
    <!-- 页面内容 -->
    <div class="contentBox">
        <div class="card">
            <div class="">
                <img :src="'http://qiuo4nrcv.hn-bkt.clouddn.com/'+setmeal.img" width="100%" height="100%"/>
            </div>
            <div class="project-text">
                <h4 class="tit">{{setmeal.name}}</h4>
                <p class="subtit">{{setmeal.remark}}</p>
                <p class="keywords">
                    <span>{{setmeal.sex == '0' ? '性别不限' : setmeal.sex == '1' ? '男':'女'}}</span>
                    <span>{{setmeal.age}}</span>
                </p>
            </div>
            <div class="project-know">
                <a href="orderNotice.html" class="link-page">
                    <i class="icon-ask-circle"><span class="path1"></span><span class="path2"></span></i>
                    <span class="word">预约须知</span>
                    <span class="arrow"><i class="icon-rit-arrow"></i></span>
                </a>
            </div>
        </div>
        <div class="form-info">
            <div class="info-title">
                <span class="name">体检人信息</span>
            </div>
            <form class="info-form">
                <div class="input-row">
                    <label>体检人</label>
                    <input v-model="orderInfo.name" type="text" class="input-clear" placeholder="请输入姓名">
                </div>
                <div class="input-row single-radio">
                    <label class="radio-title">性别</label>
                    <div class="radio-list">
                        <div class="radio">
                            <input v-model="orderInfo.sex" id="item1" type="radio" name="sex" value="1" checked>
                            <label for="item1"></label>
                            <span>男</span>
                        </div>
                        <div class="radio">
                            <input v-model="orderInfo.sex" id="item2" type="radio" name="sex" value="2">
                            <label for="item2"></label>
                            <span>女</span>
                        </div>
                    </div>
                </div>
                <div class="input-row">
                    <label>手机号</label>
                    <input v-model="orderInfo.telephone" type="text" class="input-clear" placeholder="请输入手机号">
                    <input style="font-size: x-small;" id="validateCodeButton" @click="sendValidateCode()" type="button"
                           value="发送验证码">
                </div>
                <div class="input-row">
                    <label>验证码</label>
                    <input v-model="orderInfo.validateCode" type="text" class="input-clear" placeholder="请输入验证码">
                </div>
                <div class="input-row">
                    <label>身份证号</label>
                    <input v-model="orderInfo.idCard" type="text" class="input-clear" placeholder="请输入身份证号">
                </div>

                <div class="input-row">
                    <label>预约地址</label>
                    <input type="text" id="A" v-model="orderInfo.address" placeholder="点击下方按钮可以选择健康中心地址">
                    <el-row>
                        <el-button type="primary" icon="el-icon-location" onclick="$('#allmap').toggle();">查看地图定位
                        </el-button>
                    </el-row>
                </div>
                <div class="input-row">
                    <el-button type="success" icon="el-icon-s-promotion" onclick=setCenter()>安徽省省立医院</el-button>
                    <el-button type="success" icon="el-icon-s-promotion" onclick=setCenter1()>合肥市二院</el-button>
                    <el-button type="success" icon="el-icon-s-promotion" onclick=setCenter2()>合肥中医药第一附属医院</el-button>
                    &nbsp;&nbsp;&nbsp;&nbsp;<el-button type="warning" icon="el-icon-place"
                                                       onclick="$('#dddd').toggle();">查看第一视角
                </el-button>

                </div>
                <div id="allmap"></div>


                <div id="dddd">
                    <div id="panorama"></div>
                    <div id="result">
                        <div>
                            <button id="hideAlbumsControl">隐藏全景相册控件</button>
                            <button id="showAlbumsControl">显示全景相册控件</button>
                        </div>
                    </div>
                </div>

                <div class="date">
                    <label>体检日期</label>
                    <i class="icon-date" class="picktime"></i>
                    <input v-model="orderInfo.orderDate" type="text" class="picktime" readonly>
                </div>
            </form>

            <div class="box-button">
                <button @click="submitOrder()" type="button" class="btn order-btn">提交预约</button>
            </div>

        </div>

        <div style="text-align: center">

            <a href="Earth1.html" target="_blank" style="color: #aa00aa">
                或许换个角度看看这个更大的世界？
            </a>

        </div>
    </div>
</div>
<script>
    var vue = new Vue({
        el: '#app',
        data: {
            link: '1',
            address: {},
            setmeal: {},//套餐信息
            addressId: "",
            addr: "",
            orderInfo: {
                setmealId: id,
                sex: '1'
            }//预约信息
        },
        methods: {
            aa() {
                var panorama = new BMap.Panorama('panorama', {
                    albumsControl: true //默认为不显示相册控件，默认值为false
                });
                panorama.setPosition(new BMap.Point(117.369344, 31.860053));
                panorama.setPov({pitch: 5.04, heading: 343.92});
            },


            bb(){
                var panorama = new BMap.Panorama('panorama', {
                    albumsControl: true //默认为不显示相册控件，默认值为false
                });
                panorama.setPosition(new BMap.Point(117.267456, 31.860184));
                panorama.setPov({pitch: 5.04, heading: 343.92});
            },
            //发送验证码
            sendValidateCode() {
                //获取用户的手机号
                var telephone = this.orderInfo.telephone
                //调用js方法，校验输入的手机号是否合法
                if (!checkTelephone(telephone)) {
                    //校验不通过，提示错误信息
                    this.$message({
                        type: 'error',
                        message: "请输入正确的手机号哦( •̀ ω •́ )",
                        center: true
                    });
                    return false;
                }
                //在按钮上显示46秒倒计时
                //锁定dom对象(jquery转换成js对象)
                validateCodeButton = $("#validateCodeButton")[0];
                //jquery转换成js对象（原始方法）
                //validateCodeButton=document.getElementById("validateCodeButton");
                //定时器方法，可以实现每隔指定时间调用指定方法
                clock = window.setInterval(doLoop, 1000);
                //发送Ajax请求，为用户发送手机验证码
                axios.post("/validateCode/send4Order.do?telephone=" + telephone).then((res) => {
                    if (!res.data.flag) {
                        //短信发送失败
                        this.$message({
                            type: 'error',
                            message: res.data.message,
                            center: true
                        });
                    }
                });
            },
            //提交预约
            submitOrder() {
                //1.对用户输入的手机号再次进行校验！！！！
                //获取用户的手机号
                var telephone = this.orderInfo.telephone
                //调用js方法，校验输入的手机号是否合法
                if (!checkTelephone(telephone)) {
                    //校验不通过，提示错误信息
                    this.$message({
                        type: 'error',
                        message: "大人，检查一下您的手机号是否输入正确(￣▽￣)",
                        center: true
                    });
                    return false;
                }
                //2.对用户输入的身份证号进行校验
                var idCard = this.orderInfo.idCard;
                if (!checkIdCard(idCard)) {
                    //身份证号输入不合法
                    this.$message({
                        type: 'error',
                        message: "这是人的身份证号嘛,,ԾㅂԾ,,",
                        center: true
                    });
                    return false;
                }
                //3.发送Ajax请求，提交表单数据到后台进行业务处理
                axios.post("/order/submit.do", this.orderInfo).then((res) => {
                    if (res.data.flag) {
                        //预约成功，跳转到成功页面
                        window.location.href = "orderSuccess.html?orderId=" + res.data.data;
                    } else {
                        //预约失败,弹出提示信息
                        this.$message({
                            type: 'error',
                            message: res.data.message,
                            center: true
                        });
                    }
                })
            }
        },
        mounted() {
            this.aa();

            $('#dddd').toggle();
            $('#allmap').toggle();


            //发动Ajax请求，根据套餐ID查询套餐信息，用于页面展示
            axios.post("/setmeal/findById.do?id=" + id).then((res) => {
                if (res.data.flag) {
                    //查询成功，为模型数据赋值
                    this.setmeal = res.data.data;
                }
            });

            $.get("http://localhost:82/map/findAllAddress.do", function (res) {
                if (res.flag) {
                    this.address = res.data;
                    /* alert(this.address[0].address);*/
                } else {
                    this.$message.error(res.data.message);
                }
            });
        }

    });
</script>

<script>
    //日期控件
    var calendar = new datePicker();
    calendar.init({
        'trigger': '.picktime', /*按钮选择器，用于触发弹出插件*/
        'type': 'date', /*模式：date日期；datetime日期时间；time时间；ym年月；*/
        'minDate': getSpecifiedDate(new Date(), 1), /*最小日期*/
        'maxDate': getSpecifiedDate(new Date(), 30), /*最大日期*/
        'onSubmit': function () { /*确认时触发事件*/
            //var theSelectData = calendar.value;
        },
        'onClose': function () { /*取消时触发事件*/
        }
    });
</script>
<script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
    // 创建地图对象
    var map = new BMap.Map("allmap");
    // 初始化地图,用城市名设置地图中心点，显示比例级别

    map.centerAndZoom("合肥", 12);
    //鼠标滚动缩放
    map.enableScrollWheelZoom(true);
    //添加地图类型控件
    map.addControl(new BMap.MapTypeControl());

    function setCenter() {
        var point = new BMap.Point(117.296925, 31.863743);   //根据坐标创建点
        map.centerAndZoom(point, 16);    //用点坐标设置地图中心并显示比例级别
        $("#A").val("合肥市庐阳区庐江路17号");
        /*this.link = 1;*/
        this.aa();
    }

    function setCenter1() {
        var point = new BMap.Point(117.324959, 31.862423);   //根据坐标创建点
        map.centerAndZoom(point, 16);    //用点坐标设置地图中心并显示比例级别
        $("#A").val("合肥市瑶海区广德路与乐水路交叉口龙兴家园西北侧");
        /*this.link = 2;*/
        this.bb();
    }

    function setCenter2() {
        var point = new BMap.Point(117.267456, 31.860184);   //根据坐标创建点
        map.centerAndZoom(point, 16);    //用点坐标设置地图中心并显示比例级别
        $("#A").val("安徽省合肥市蜀山区梅山路117号");
        /*this.link = 3;*/
        /*alert(this.link);*/
        this.cc();

    }
</script>

<script type="text/javascript">
    //this.aa();

    /*var i = this.link;
    alert(i);*/




    /*if (i == 2) {
        panorama.setPosition(new BMap.Point(117.369344,31.860053));
        panorama.setPov({pitch: 5.04, heading: 343.92});
    }//二院

    if (i == 1) {
        panorama.setPosition(new BMap.Point(117.296925, 31.863743));
        panorama.setPov({pitch: 5.04, heading: 343.92});
    }//安徽省合肥市省立医院
    if (i==3){
        panorama.setPosition(point);
        panorama.setPov({pitch: 5.04, heading: 343.92});
    }*/


    //设置相册位置为右上角
    panorama.setOptions({
        albumsControlOptions: {
            anchor: BMAP_ANCHOR_TOP_RIGHT
        }
    });

    //设置偏移量，距离上面15px，距离左边100px（距离那边受anchor位置的影响）
    panorama.setOptions({
        albumsControlOptions: {
            offset: new BMap.Size(100, 15)
        }
    });

    //设置相册的长度和图片大小,相册的最大宽度为60%，相册内图片的大小为80px
    panorama.setOptions({
        albumsControlOptions: {
            maxWidth: '60%',
            imageHeight: 80
        }
    });

    //隐藏相册
    document.getElementById("hideAlbumsControl").onclick = function () {
        panorama.setOptions({
            albumsControl: false
        });
    };

    //显示相册
    document.getElementById("showAlbumsControl").onclick = function () {
        panorama.setOptions({
            albumsControl: true
        });
    };
</script>

</body>
</html>